package cn.com.cennavi.bean;

import java.io.Serializable;

public class DiDiTrajectory implements Serializable {
	private static final long serialVersionUID = 1L;
	/**
	 * 车辆id
	 */
	public String id;
	// /**
	// * gps点序列
	// */
	// public String gpsSeq;
	/**
	 * 匹配出来的gps点时间戳
	 */
	public String gpsTimeSeq;
	/**
	 * 匹配出来的gps投影到起始link的距离
	 */
	public String gpsDisSeq;
	/**
	 * 匹配出来的link序列
	 */
	public String linkSeq;
	/**
	 * 分岔口id
	 */
	public String difPointId;
	/**
	 * 方向
	 */
	public int dir;
	// /**
	// * gps点投影起点距离
	// */
	// public String pointDisSeq;
	/**
	 * 时间戳
	 */
	public long timeStamp;
	/**
	 * 目前道路的角度
	 */
	public String angle;
	/**
	 * 分歧点经纬度
	 */
	public String lonLat;
	/**
	 * 分歧点的位置
	 */
	public int difPointDis;
	/**
	 * 分歧点距离末尾link的位置
	 */
	public int difPointDisToStartLink;
	/**
	 * 目前道路所属分岔口，直行道路的角度
	 */
	public String straightAngle;
	/**
	 * 两位标示，00表示左出，10表示右出，01表示左入，11表示右入
	 */
	public String difPointDirClass;
	/**
	 * 每一个gps点的速度kmph
	 */
	public String speedSeq;
	/**
	 * 轨迹用到的carId
	 */
	public String carId;
	/**
	 * roadClass:0封闭道路，1地面道路
	 * 
	 * @return
	 */
	public int roadClass;
	/**
	 * 车道序列号，代表该条道路那几个车道
	 * 
	 * @param closeRoadMapData
	 * @param roadClass
	 */
	public String inlaneNoSeq;
	/**
	 * 车道序列号，代表该条道路那几个车道
	 * 
	 * @param closeRoadMapData
	 * @param roadClass
	 */
	public String outlaneNoSeq;
	/**
	 * 进出link对
	 */
	public String inoutLink;
	/**
	 * link长度序列
	 */
	public String linkLenSeq;

	public String toShowString() {
		StringBuffer sb = new StringBuffer();
		// sb.append(this.linkSeq);
		// sb.append("_");
		sb.append(this.difPointId);
		sb.append("_");
		sb.append(this.dir);
		// sb.append("_");
		// sb.append(this.timeStamp);
		// sb.append("_");
		// sb.append(this.angle);
		sb.append("_");
		sb.append(this.lonLat);
		// sb.append("_");
		// sb.append(this.difPointDis);
		sb.append("_");
		sb.append(this.straightAngle);
		sb.append("_");
		sb.append(this.difPointDirClass);
		// sb.append("_");
		// sb.append(this.gpsTimeSeq);
		// sb.append("_");
		// sb.append(this.gpsDisSeq);
		sb.append("_");
		sb.append(this.difPointDisToStartLink);
		sb.append("_");
		sb.append(this.roadClass);
		return sb.toString();
	}

	public String toString() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.id);
		// sb.append(",");
		// sb.append(this.gpsSeq);
		sb.append(",");
		sb.append(this.linkSeq);
		sb.append(",");
		sb.append(this.difPointId);
		sb.append(",");
		sb.append(this.dir);
		// sb.append(",");
		// sb.append(this.pointDisSeq);
		sb.append(",");
		sb.append(this.timeStamp);
		sb.append(",");
		sb.append(this.angle);
		sb.append(",");
		sb.append(this.lonLat);
		sb.append(",");
		sb.append(this.difPointDis);
		sb.append(",");
		sb.append(this.straightAngle);
		sb.append(",");
		sb.append(this.difPointDirClass);
		sb.append(",");
		sb.append(this.gpsTimeSeq);
		sb.append(",");
		sb.append(this.gpsDisSeq);
		sb.append(",");
		sb.append(this.difPointDisToStartLink);
		return sb.toString();
	}

	public String toString1() {
		StringBuffer sb = new StringBuffer();
		sb.append(this.id);
		// sb.append(",");
		// sb.append(this.gpsSeq);
		sb.append(",");
		sb.append(this.linkSeq);
		sb.append(",");
		sb.append(this.difPointId);
		sb.append(",");
		sb.append(this.dir);
		// sb.append(",");
		// sb.append(this.pointDisSeq);
		sb.append(",");
		sb.append(this.timeStamp);
		sb.append(",");
		sb.append(this.angle);
		sb.append(",");
		sb.append(this.lonLat);
		sb.append(",");
		sb.append(this.difPointDis);
		sb.append(",");
		sb.append(this.straightAngle);
		sb.append(",");
		sb.append(this.difPointDirClass);
		sb.append(",");
		sb.append(this.gpsTimeSeq);
		sb.append(",");
		sb.append(this.gpsDisSeq);
		sb.append(",");
		sb.append(this.speedSeq);
		sb.append(",");
		sb.append(this.difPointDisToStartLink);
		return sb.toString();
	}

	public static DiDiTrajectory parseData(String line) {
		String[] arr = line.split(",");
		if (arr.length >= 13) {
			DiDiTrajectory didi = new DiDiTrajectory();
			didi.id = arr[0];
			didi.linkSeq = arr[1];
			didi.difPointId = arr[2];
			didi.dir = Integer.parseInt(arr[3]);
			didi.timeStamp = Long.parseLong(arr[4]);
			didi.angle = arr[5];
			didi.lonLat = arr[6];
			didi.difPointDis = Integer.parseInt(arr[7]);
			didi.straightAngle = arr[8];
			didi.difPointDirClass = arr[9];
			didi.gpsTimeSeq = arr[10];
			didi.gpsDisSeq = arr[11];
			didi.difPointDisToStartLink = Integer.parseInt(arr[12]);
			return didi;
		}
		return null;

	}

	public static DiDiTrajectory getDiDiTrajectory(String key, String linkseq2) {
		// TODO Auto-generated constructor stub
		String[] carId_dir_links = linkseq2.split("\\*");
		if (carId_dir_links.length < 5)
			return null;
		String[] mapData = carId_dir_links[3].split(",");
		String gpstime = carId_dir_links[4];
		String gpsdis = carId_dir_links[5];
		DiDiTrajectory didi = new DiDiTrajectory();
		didi.difPointDisToStartLink = Integer.parseInt(mapData[12]);
		didi.id = key;
		didi.gpsTimeSeq = gpstime;
		didi.gpsDisSeq = gpsdis;
		didi.linkSeq = carId_dir_links[2];
		didi.difPointId = mapData[5];
		didi.dir = Integer.parseInt(mapData[9]);
		didi.timeStamp = 01l;// getTimeStamp(gpstime);
		didi.angle = mapData[8];
		didi.lonLat = mapData[6] + "|" + mapData[7];
		didi.difPointDis = Integer.parseInt(mapData[3]);
		didi.straightAngle = mapData[11];
		didi.difPointDirClass =mapData[10];
//		didi.inlaneNoSeq = mapData[15];
//		didi.outlaneNoSeq = mapData[16];
		didi.inoutLink = mapData[4];
		didi.linkLenSeq = mapData[13];
//		didi.speedSeq = carId_dir_links[6];
		didi.roadClass = Integer.parseInt(carId_dir_links[6]);
		return didi;
	}

	public DiDiTrajectory() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		// TODO Auto-generated method stub

	}

}
